package com.ryskoo.framework.core.service;

import com.ryskoo.framework.core.bean.BasicPO;
import com.ryskoo.framework.core.bean.QueryMessageDTO;
import com.ryskoo.framework.core.repository.IBasicRepository;

import java.util.List;

public class BasicServiceImpl<M extends BasicPO> implements IBasicService<M> {

	protected IBasicRepository<M> dao;

	public void setDao(IBasicRepository<M> dao) {
		this.dao = dao;
	}

	@Override
	public void create(M m) {
		dao.create(m);
	}

	@Override
	public void update(M m) {
		dao.update(m);
	}

    @Override
    public void createOrUpdate(M m) {
        dao.createOrUpdate(m);
    }

	@Override
	public void delete(M m) {
		dao.delete(m);
	}

	@Override
	public void deletes(List<String> needDeleteUuids) {
		dao.deletes(needDeleteUuids);
	}

	@Override
	public M getByUuid(String uuid) {
		return dao.getByUuid(uuid);
	}

	@Override
	public List<M> getAll() {
		return dao.getAll();
	}

	@Override
	public List<M> queryByCondition(QueryMessageDTO qm, boolean byPage) {
		return dao.queryByCondition(qm, byPage);
	}

	@Override
	public List<M> queryByCondition(QueryMessageDTO qm) {
		return this.queryByCondition(qm, false);
	}

	@Override
	public List<M> queryByConditionAndPage(QueryMessageDTO qm) {
		return this.queryByCondition(qm, true);
	}

    @Override
    public List<M> queryByNativeSql(QueryMessageDTO qm) throws NoSuchFieldException {
        return dao.queryByNativeSql(qm, true);
    }

	@Override
	public List<String> getUuidsByCondition(QueryMessageDTO qm, boolean byPage) {
		return dao.getUuidsByCondition(qm, byPage);
	}

	@Override
	public List<String> getUuidsByCondition(QueryMessageDTO qm) {
		return dao.getUuidsByCondition(qm, false);
	}

	@Override
	public List<String> getUuidsByConditionAndPage(QueryMessageDTO qm) {
		return this.getUuidsByCondition(qm, true);
	}

	@Override
	public int getCount(QueryMessageDTO qm) {
		return dao.getCount(qm);
	}

	@Override
	public int getCountByNativeSql(QueryMessageDTO qm) throws NoSuchFieldException {
		return dao.getCountByNativeSql(qm);
	}
	
    /**
     * 批量新增
     */
	@Override
	public void batchCreate(List<M> paramList) {
		dao.batchCreate(paramList);
	}

	
	/**
	 * 批量更新
	 */
	@Override
	public void batchUpdate(List<M> paramList) {
       dao.batchUpdate(paramList);
	}

}
